dnl Process this file with autoconf to produce a configure script.

AC_INIT([Prune], 0.1, [at@gclab.org])
AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)

dnl ======================================================================
dnl check for programs
dnl ======================================================================
AC_PATH_PROG(RUBY, ruby, no)
if test "$RUBY" = "no"; then
   AC_MSG_ERROR([Couldn't find ruby program. Please install the Ruby first.])
fi
AC_SUBST(RUBY)

AC_PATH_PROG(RACC, racc, no)
if test "$RACC" = "no"; then
   AC_MSG_ERROR([Couldn't find racc program. Please install the Racc first.])
fi
AC_SUBST(RACC)

AC_PATH_PROG(RDOC, rdoc, no)
if test "$RDOC" = "no"; then
   AC_PATH_PROG(RDOC18, rdoc1.8, no)
   RDOC=$RDOC18
fi

dnl ======================================================================
dnl options
dnl ======================================================================
AC_ARG_ENABLE(docgen,
	AC_HELP_STRING([--enable-docgen],
		[Whether or not generate the documentation at the build time. (default:yes)]),
	[docgen=$enableval],
	[docgen=true])
AC_ARG_WITH(rubydir,
	AC_HELP_STRING([--with-rubydir=DIR],
		[ruby libraries directory [[LIBDIR/ruby/RUBY_VERSION]]]),
	[rubydir=$withval],
	[rubydir='$(libdir)/site_ruby/$(RUBYVERSION)'])

dnl ======================================================================
dnl options - docgen
dnl ======================================================================
AM_CONDITIONAL(USE_RDOC, test $RDOC != no && test $docgen == true)

dnl ======================================================================
dnl options - rubydir
dnl ======================================================================
RUBYLIBDIR=$rubydir
AC_SUBST(RUBYLIBDIR)

dnl ======================================================================
dnl set the substance of the values
dnl ======================================================================
RUBYVERSION=`$RUBY -r rbconfig -e "puts Config::CONFIG[['ruby_version']]"`
AC_SUBST(RUBYVERSION)
BASEDIR="$datarootdir/prune"
AC_SUBST(BASEDIR)
PLUGINDIR="$BASEDIR/plugins"
AC_SUBST(PLUGINDIR)
changequote(,)dnl
MAJOR_VERSION="`echo $PACKAGE_VERSION | sed -e 's/\(^[0-9]*\)\..*/\1/'`"
MINOR_VERSION="`echo $PACKAGE_VERSION | sed -e 's/^[0-9]*\.\([0-9]*\).*/\1/'`"
changequote([,])
AC_SUBST(MAJOR_VERSION)
AC_SUBST(MINOR_VERSION)

dnl ======================================================================
dnl output
dnl ======================================================================
AC_CONFIG_FILES([
Makefile
prune/Makefile
prune/version.rb
])
AC_OUTPUT
